#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__title__ = ''
__author__ = 'HaiFeng'
__mtime__ = '2016/12/15'
"""

from app import socketio
from flask_socketio import emit, join_room, leave_room, rooms, disconnect
import zmq
import struct
import time


thread = None




def background_thread():
    while True:
        print('循环开始')
        socketio.emit('clickdome', '', namespace='/adong')
        time.sleep(1)


@socketio.on("connect", namespace='/adong')
def connect():
    print('adong')

@socketio.on('getinsts', namespace='/adong')
def getinsts(message):


    print('前台发送的信息接收到了'+message)

    global thread
    if thread is None:
        thread = socketio.start_background_task(target=background_thread)
    # time.sleep(3)
    # socketio.emit('clickdome', '', namespace='/adong')
    # time.sleep(5)
    # socketio.emit('clickdome', '', namespace='/adong')




